import pandas as pd
import numpy as ny

data_frame = pd.DataFrame(ny.random.randint(1, 10, (3, 4)), index=list('abc'), columns=list('ABCD'))
print(data_frame)

# 按内容排序，ascending控制升序、降序
sort_values = data_frame.sort_values(by='B', ascending=False)
print(sort_values)

# 按多字段的内容排序
multi_sort_values = data_frame.sort_values(by=['B', 'C'], ascending=False)
print(multi_sort_values)

# 按索引排序
index_sort_index = data_frame.sort_index(ascending=False)
print(index_sort_index)

# series排序
pd_series = pd.Series([11, 22, 33, 44])
sort_series = pd_series.sort_values(ascending=False)
print(sort_series)
